import 'package:flutter/material.dart';
import "package:get/get.dart";

import '../../../components/appbar_widget/appbar_widget.dart';
import '../../../components/loading/svg_loading.dart';
import '../../../components/status/empty.dart';
import '../../../components/status/not_network.dart';
import '../../../config/global_config.dart';
import '../../../controller/network/network_ctrl.dart';
import '../../../utils/screenutil/fit.dart';
import 'ctrl/repairs_details_ctrl.dart';

class RepairsDetails extends StatelessWidget {
  // 导入控制器
  final rdCtrl = Get.put(RepairsDetailsCtrl());
  final _nc = Get.find<NetworkCtrl>();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBarWidget("报修详情").build(context),
      body: Obx(
        () => Container(
          height: double.infinity,
          child: Stack(
            children: [
              rdCtrl.isInitComplete.value
                  ? Container(
                      margin: EdgeInsets.only(
                        top: fit(_nc.topDistance.value),
                      ),
                      child: rdCtrl.MARKSYMBOL.value
                          ? SingleChildScrollView(
                              child: Container(
                                child: Column(
                                  children: [
                                    createContainer("电梯位置：",
                                        "${rdCtrl.pageData.value.buildingName}"),
                                    createContainer("报修时间：",
                                        "${rdCtrl.pageData.value.createTime}"),
                                    createContainer("维修内容：",
                                        "${rdCtrl.pageData.value.content}"),
                                  ],
                                ),
                              ),
                            )
                          : Container(
                              width: 640.f,
                              child: Empty(),
                            ),
                    )
                  : SVGLoading(),

              // 网络状态
              Positioned(top: 0, child: NotNetwork()),

              // 提交按钮
              rdCtrl.type == 0
                  ? Positioned(
                      bottom: 0,
                      child: Container(
                        width: 640.f,
                        color: GlobalConfig.theme,
                        child: MaterialButton(
                          highlightColor: Colors.transparent,
                          splashColor: Colors.transparent,
                          onPressed: () => rdCtrl.changeRepairsStatus(),
                          child: Text(
                            "已维修",
                            style: TextStyle(
                              fontSize: 24.f,
                              color: Colors.white,
                            ),
                          ),
                        ),
                      ),
                    )
                  : SizedBox.shrink(),
            ],
          ),
        ),
      ),
    );
  }

  /// -
  /// * [title] String|标题|必填
  /// * [content] String|内容|必填
  Widget createContainer(String title, String content) {
    return Container(
      padding: EdgeInsets.symmetric(vertical: 15.f, horizontal: 20.f),
      color: Colors.white,
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: [
          Text(
            "$title",
            style: TextStyle(
              fontSize: 24.f,
              color: GlobalConfig.assistColor,
            ),
          ),
          Container(
            width: 450.f,
            alignment: Alignment.centerRight,
            child: Text(
              "$content",
              textAlign: TextAlign.right,
              style: TextStyle(
                fontSize: 24.f,
              ),
            ),
          ),
        ],
      ),
    );
  }
}

/*
Container(
          child: Stack(
            children: [
              rdCtrl.isInitComplete.value
                  ? Container(
                      margin: EdgeInsets.only(
                        top: fit(_nc.topDistance.value),
                      ),
                      child: rdCtrl.MARKSYMBOL.value
                          ? SingleChildScrollView(
                              child: Container(
                                child: Column(
                                  children: [
                                    createContainer("电梯位置：",
                                        "${rdCtrl.pageData.value.buildingName}"),
                                    createContainer("报修时间：",
                                        "${rdCtrl.pageData.value.createTime}"),
                                    createContainer("维修内容：",
                                        "${rdCtrl.pageData.value.content}"),
                                  ],
                                ),
                              ),
                            )
                          : Container(
                              width: 640.f,
                              child: Empty(),
                            ),
                    )
                  : SVGLoading(),

              // 网络状态
              Positioned(top: 0, child: NotNetwork()),

              Positioned(
                bottom: 0,
                child: Container(
                  child: Text("asd"),
                ),
              ),
            ],
          ),
        )
 */
